package com.yusheng.controller;

import com.google.gson.Gson;
import com.yusheng.dao.QueryStaff;
import com.yusheng.entity.Stuff;
import com.yusheng.entity.StuffList;
import com.yusheng.util.JdbcUtil;
import org.omg.CORBA.Request;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

//@WebServlet(name = "SignIn", value = "/SignIn")
public class
SignIn extends HttpServlet {


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //用户登录，设计到密码等重要信息，需要post隐藏一下
        Gson gson=new Gson();
        InputStream in= request.getInputStream();//运用ajax传过来的数据，不能用向表单那样的方法获得，需要用输入流获取
        byte[] bytes=new byte[50];
        in.read(bytes);//read读取到byte数组中，然后再转成String类型
        String account=new String(bytes);
        //QueryStaff.jdbcUtil=new JdbcUtil();
        Stuff stuff=QueryStaff.queryStuffByNo(account);
        String s=gson.toJson(stuff);
        response.setContentType("type=type/html;charset=utf-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out= response.getWriter();
        out.print(s);



    }
}
